var _n83;
var cc__extends = __extends;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $zqcc_OverallSystem = require("zqcc_OverallSystem");
var $miniGameApiBase = require("miniGameApiBase");
var s = window.qg;
var def_vivoApi = function (t) {
  function _ctor() {
    var e = null !== t && t.apply(this, arguments) || this;
    e.m_AppId = "";
    e.m_Secret = "";
    e.m_VideoAdIdIndex = 0;
    e.m_VideoAdIdList = ["240a2919d9684d4d9a9ac0d79619635d"];
    e.m_BannerAdIdIndex = 0;
    e.m_BannerAdId = ["9942cc2afd0f41ac8241b38c86ef2eec"];
    e.m_InsertAdIdIndex = 0;
    e.m_InsertAdId = [];
    e.m_videoAd = undefined;
    e.m_BannerAd = undefined;
    e.bannerSuccese = false;
    return e;
  }
  cc__extends(_ctor, t);
  _ctor.prototype.validAppId = function () {
    console.log("vivo-api-validAppId");
    s.onShow(function () {
      $zqcc_OverallSystem.mgrs().soundMgr.playMusic("bgm");
    });
  };
  _ctor.prototype.ready = function () {
    console.log("vivo-api-ready");
  };
  _ctor.prototype.getUserInfo = function (t) {
    s.getUserInfo(t);
  };
  _ctor.prototype.showToast = function (t) {
    s.showToast(t);
  };
  _ctor.prototype.showLoading = function (t) {
    s.showLoading(t);
  };
  _ctor.prototype.hideLoading = function () {
    s.hideLoading();
  };
  _ctor.prototype.showModal = function () {};
  _ctor.prototype.authorize = function (t) {
    t.success && t.success();
  };
  _ctor.prototype.login = function (t) {
    s.login(t);
  };
  _ctor.prototype.FullScreenVideoAd = function () {};
  _ctor.prototype.reportAnalytics = function () {};
  _ctor.prototype.getVideoAdId = function () {
    var t = this.m_VideoAdIdList[this.m_VideoAdIdIndex];
    this.m_VideoAdIdIndex++;
    this.m_VideoAdIdIndex >= this.m_VideoAdIdList.length && (this.m_VideoAdIdIndex = 0);
    return t;
  };
  _ctor.prototype.loadAndShowVideoAd = function (t, e, o) {
    var n = this;
    this.showLoading({
      message: "请求中"
    });
    null == this.m_videoAd && (this.m_videoAd = s.createRewardedVideoAd({
      adUnitId: this.getVideoAdId()
    }));
    var i = function i(r) {
      if (r && r.isEnded) {
        t();
      } else {
        e("视频中途退出");
      }
      n.m_videoAd.offClose(i);
      o && o();
    };
    this.m_videoAd.load().then(function () {
      n.m_videoAd.show().then(function () {
        n.hideLoading();
        n.m_videoAd.onClose(i);
      }).catch(function (t) {
        n.showToast({
          title: "视频加载错误",
          icon: "none"
        });
        n.hideLoading();
        e("视频显示错误  :" + JSON.stringify(t));
        n.m_videoAd.offClose(i);
        o && o();
      });
    }).catch(function (t) {
      n.showToast({
        title: "视频加载错误",
        icon: "none"
      });
      n.hideLoading();
      e("视频加载错误  :" + JSON.stringify(t));
      n.m_videoAd.offClose(i);
      o && o();
    });
  };
  _ctor.prototype.getInsertAdId = function () {
    var t = this.m_InsertAdId[this.m_InsertAdIdIndex];
    this.m_InsertAdIdIndex++;
    this.m_InsertAdIdIndex >= this.m_InsertAdId.length && (this.m_InsertAdIdIndex = 0);
    return t;
  };
  _ctor.prototype.showInsertAd = function (t, e) {
    console.log("加抖音 插屏 广告");
    var o = this.getInsertAdId();
    var n = s.createInterstitialAd({
      adUnitId: o
    });
    n.load();
    n.onLoad(function () {
      console.warn("插屏广告 加载完成");
      n.show().catch(function (t) {
        console.warn("插屏广告 显示失败 :" + JSON.stringify(t));
        n.destroy();
        n = null;
        e && e();
      });
    });
    n.onError(function (t) {
      console.warn("插屏广告 加载失败" + JSON.stringify(t));
      n.destroy();
      n = null;
      e && e();
    });
    n.onClose(function () {
      console.warn("插屏广告 关闭");
      if (null != n) {
        n.destroy();
        n = null;
      }
      t && t();
    });
  };
  _ctor.prototype.getBannerAdId = function () {
    var t = this.m_BannerAdId[this.m_BannerAdIdIndex];
    this.m_BannerAdIdIndex++;
    this.m_BannerAdIdIndex >= this.m_BannerAdId.length && (this.m_BannerAdIdIndex = 0);
    return t;
  };
  _ctor.prototype.showBannerAD = function (t, e, o, n, i) {
    var r = this;
    var a = s.getSystemInfoSync();
    var c = a.screenWidth;
    var l = a.screenHeight;
    var u = i && i({
      screenWidth: c,
      screenHeight: l
    }) || cc.v2(0, 0);
    if (this.m_BannerAd && !this.bannerSuccese) {
      this.m_BannerAd.destroy();
      this.m_BannerAd = null;
    }
    if (this.m_BannerAd) {
      this.m_BannerAd.show().then(function () {
        e && e();
        console.log("---------------------Banner广告直接显示成功");
      }).catch(function (t) {
        o && o(t);
        console.log("---------------------Banner广告直接显示组件出现问题", JSON.stringify(t));
      });
    } else {
      this.bannerSuccese = true;
      null == this.m_BannerAd && (this.m_BannerAd = s.createBannerAd({
        posId: this.getBannerAdId(),
        adIntervals: 30,
        style: {
          left: u.x,
          top: u.y
        }
      }));
      this.m_BannerAd.onSize(function (t) {
        console.log(t.width, t.height, "------------banner长宽-----------");
      });
      this.m_BannerAd.onLoad(function () {
        if (null != t && t.active && t.isValid) {
          r.bannerSuccese = false;
          r.m_BannerAd.show().then(function () {
            e && e();
            console.log("---------------------Banner广告显示成功");
            r.m_BannerAd.onClose(function () {
              n && n();
            });
          }).catch(function (t) {
            o && o(t);
            console.log("---------------------Banner广告组件显示出现问题" + t.errCode + " :" + t.errMsg);
          });
        } else {
          console.log("---------------------------------------------------------");
        }
      });
      this.m_BannerAd.onError(function (t) {
        r.bannerSuccese = false;
        o && o(t);
        console.log("---------------------Banner广告加载错误,错误原因：" + t.errCode + " :" + t.errMsg);
      });
    }
  };
  _ctor.prototype.hideBanner = function () {};
  _ctor.prototype.recordedGameScreenStart = function (t, e) {
    console.log("vivo-api-recordedGameScreenStart");
    e && e(null);
  };
  _ctor.prototype.recordedGameScreenStop = function () {
    console.log("vivo-api-recordedGameScreenStop");
    return true;
  };
  _ctor.prototype.shareRecordedGameScreen = function (t) {
    console.log("vivo-api-shareRecordedGameScreen");
    t && t();
  };
  _ctor.prototype.isHaveRecordedGameScreen = function () {
    return true;
  };
  return _ctor;
}($miniGameApiBase.MiniGameApiBase);
exports.default = def_vivoApi;